package com.qingzhuge.netty.common.message;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @author : zero.xiao
 * @description :
 * @date :2018/9/28 0028 下午 14:48
 * @modified :
 * @since : 1.0.0
 */
public class MessageEncoder extends MessageToByteEncoder<HeartBeatMessage> {

    @Override
    protected void encode(ChannelHandlerContext ctx, HeartBeatMessage msg, ByteBuf out) {
        String heartBeat = msg.getHeartbeat();
        out.writeBytes(heartBeat.getBytes());
    }
}
